var t = getApp();

Page({
    data: {
        List1: [],
        lastid: 0,
        toastHidden: !0,
        confirmHidden: !0,
        isfrist: 1,
        loadHidden: !0,
        moreHidden: "none",
        msg: "——加载更多——",
        url: "con",
        base: "M",
        Listurl: "",
        TopName: "",
        bol: "",
        condition: !0
    },
    loadData: function(a, e) {
        wx.showToast({
            title: "数据加载中",
            icon: "loading",
            duration: 2e4
        });
        var o = this, n = this.data.Listurl;
        wx.request({
            url: t.url + "addon/" + n + "getAskList",
            data: {
                lastid: a,
                limit: e
            },
            method: "GET",
            header: {
                "Content-Type": "application/json",
                Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
            },
            success: function(t) {
                if (wx.hideToast(), !t.data) return o.setData({
                    toastHidden: !1
                }), o.setData({
                    moreHidden: "none"
                }), o.setData({
                    msg: "——你尚没有咨询过问题——",
                    bol: !0
                }), !1;
                var e = t.data.length, n = a;
                o.setData({
                    lastid: t.data[e - 1].id
                });
                var s = t.data;
                0 == n && wx.setStorageSync("List1", s), o.setData({
                    List1: s,
                    bol: !0
                }), o.setData({
                    moreHidden: ""
                });
            },
            fail: function(t) {
                if (o.setData({
                    msg: "--当前网络异常，请检查网络或稍后再试--",
                    bol: !0
                }), wx.hideToast(), wx.showToast({
                    title: "无法连接网络",
                    icon: "loading",
                    duration: 2700
                }), 0 == a) {
                    var e = wx.getStorageSync("List1");
                    if (!e) {
                        o.setData({
                            List1: e
                        }), o.setData({
                            moreHidden: ""
                        });
                        var n = e.length;
                        o.setData({
                            lastid: e[n - 1].id
                        });
                    }
                } else o.setData({
                    toastHidden: !1,
                    moreHidden: "none",
                    msg: "当前网络异常，请稍后再试",
                    bol: !0
                });
            },
            complete: function() {
                o.setData({
                    loadHidden: !0
                });
            }
        });
    },
    onLoad: function(t) {
        var a = t.Listurl, e = t.TopName;
        this.setData({
            Listurl: a,
            TopName: e
        });
    },
    onShow: function() {
        this.loadData(0, 2);
    },
    Open: function(t) {
        t.target.dataset.index, t.target.dataset.list, this.data.TopName;
    },
    openAnswer: function(a) {
        wx.showToast({
            title: "数据加载中",
            icon: "loading",
            duration: 2e4
        });
        var e = this, o = a.target.dataset.index, n = a.target.dataset.list, s = n[o].id;
        this.setData({
            question: n[o].ask
        }), wx.request({
            url: t.url + "addon/Askplat/Askplat/getAskDetail",
            data: {
                id: s
            },
            method: "GET",
            header: {
                "Content-Type": "application/json",
                Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
            },
            success: function(t) {
                wx.hideToast(), e.setData({
                    askdata: t.data,
                    condition: !1
                });
            },
            fail: function(t) {
                e.setData({
                    netbol: !1
                }), wx.hideToast(), wx.showToast({
                    title: "无法连接网络",
                    icon: "loading",
                    duration: 2500
                });
            }
        });
    },
    loadMore: function(t) {
        this.loadData(0, 300), this.setData({
            msg: "",
            bol: !0
        });
    },
    Operate: function(t) {
        var a = this, e = this.data.TopName;
        "我起草的合同" == e && wx.showActionSheet({
            itemList: [ "打开合同", "删除合同", "委托审查合同" ],
            success: function(e) {
                console.log(e.tapIndex), 0 == e.tapIndex && a.Open(t), 1 == e.tapIndex && a.delet(t), 
                2 == e.tapIndex && a.toExam(t);
            },
            fail: function(t) {
                console.log(t.errMsg);
            }
        }), "委托起草的合同" == e && wx.showActionSheet({
            itemList: [ "打开合同", "查看委托信息", "委托审查合同" ],
            success: function(e) {
                console.log(e.tapIndex), 0 == e.tapIndex && a.Open(t), 1 == e.tapIndex && a.toInfo(t), 
                2 == e.tapIndex && a.toExam(t);
            },
            fail: function(t) {
                console.log(t.errMsg);
            }
        }), "委托审查的合同" == e && wx.showActionSheet({
            itemList: [ "查看委托信息", "查看审查意见" ],
            success: function(e) {
                console.log(e.tapIndex), 0 == e.tapIndex && a.toInfo2(t), 1 == e.tapIndex && a.Open(t);
            },
            fail: function(t) {
                console.log(t.errMsg);
            }
        });
    },
    toAsk: function() {
        wx.redirectTo({
            url: "../Ask/Ask"
        });
    },
    backtoCover: function() {
        wx.switchTab({
            url: "../MyCover/MyCover"
        });
    },
    closepage: function() {
        this.setData({
            condition: !0
        });
    },
    showreply: function() {
        this.setData({
            showreply: !this.data.showreply
        });
    }
});